#include <SDL/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "camera.h"
#include "btBulletDynamicsCommon.h"

#ifndef INVERTEDPENDULUM_H_
#define INVERTEDPENDULUM_H_

class InvertedPendulum {

	GLUquadricObj* quadric;
	Camera camera;

	btDynamicsWorld *world;
	btDispatcher *dispatcher;
	btCollisionConfiguration *collisionConfig;
	btBroadphaseInterface *broadphase;
	btConstraintSolver *solver;

	btAlignedObjectArray<btCollisionShape*> collisionShapes;

protected:
	void termPhysics();
	btRigidBody *addBox(btVector3 origin, float width, float height, float depth, float mass);
	btRigidBody *addCylinder(btVector3 origin, float diameter, float height, float mass);
	btRigidBody *addPlane(btVector3 origin);
	void renderObjects();
	void renderBox(btRigidBody *body);
	void renderCylinder(btRigidBody *body);
	void renderPlane(btRigidBody *body);
	void updateDisplay();

public:
	InvertedPendulum();
	~InvertedPendulum();
	void initPhysics();
	void startSym(int width, int height, float camAngle);
};

#endif /* INVERTEDPENDULUM_H_ */
